var table_second_factory_input={
    second_factory_data :function(){return JSON.parse(getLocalInfo("table_second_factory_input.html"))},
    length          : $("[id*='draggable_second_factory_content_']").length,
    reloadLength    :function(){this.length = $("[id*='draggable_second_factory_content_']").length},
    init            : function(){
        this.reloadLength();
        console.info(this.second_factory_data().text);
        $($("[id*='draggable_second_factory_content_']")[this.length-1]).find("span").text(this.second_factory_data().text);
        $($("[id*='draggable_second_factory_content_']")[this.length-1]).find("[name='order_s_input_isReadColor']").val(this.second_factory_data().isreadcolor);
        /*$($("[id*='draggable_second_factory_content_']")[this.length-1]).find("textarea").attr("name","order_s_input_material_type_val");*/
        /*$("[id^='draggable_second_factory_content_']").find("[name='order_s_input_val_material_type']").unbind("click.dialog");
        
        $("[id^='draggable_second_factory_content_']").find("[name='order_s_input_val_material_type']").bind("click.dialog",function(){
            table_second_factory_input.sourceFactoryInputDialog(this);
        });*/
        this.eventBind();
        this.checkSpecialVal();
        this.loadFeedTotal();
        //绑定工艺事件
        Util_artsEvent.bindEvent();
    },
    checkSpecialVal:function(){
    	/*if(this.second_factory_data().special_val!=500){
    		$($("[id*='draggable_second_factory_content_']")[this.length-1]).find(".right-div-comp-right-content-for-five").hide();
    		$($("[id*='draggable_second_factory_content_']")[this.length-1]).find(".right-div-comp-right-content-for-six").hide();
    		$($("[id*='draggable_second_factory_content_']")[this.length-1]).find(".right-div-comp-right-content-for-seven").hide();
    	}else{
    		$($("[id*='draggable_second_factory_content_']")[this.length-1]).find(".right-div-comp-right-content").css("width","50%");
    		$($("[id*='draggable_second_factory_content_']")[this.length-1]).find(".right-div-comp-right-content-for-five").css("width","20%");
    	}*/
    	if(this.second_factory_data().special_val==500){//样式5
    		$($("[id*='draggable_second_factory_content_']")[this.length-1]).find(".right-div-comp-right-content").css("width","50%");
    		$($("[id*='draggable_second_factory_content_']")[this.length-1]).find(".right-div-comp-right-content-for-five").css("width","20%");
    		$($("[id*='draggable_second_factory_content_']")[this.length-1]).find("[name='order_s_input_val_feed_total']").attr("require_data_val","true");
    		$($("[id*='draggable_second_factory_content_']")[this.length-1]).find(".right-div-comp-right-content-for-six").hide();
    		$($("[id*='draggable_second_factory_content_']")[this.length-1]).find(".right-div-comp-right-content-for-seven").hide();
    		$($("[id*='draggable_second_factory_content_']")[this.length-1]).find(".right-div-comp-right-content-for-eight").hide();
    		$($("[id*='draggable_second_factory_content_']")[this.length-1]).find(".right-div-comp-right-content-for-nine").hide();
    		return;
    	}
    	if(this.second_factory_data().special_val==600){//样式6
    		$($("[id*='draggable_second_factory_content_']")[this.length-1]).find(".right-div-comp-right-content").css("width","49%");
    		$($("[id*='draggable_second_factory_content_']")[this.length-1]).find(".right-div-comp-left-text").css("width","10%");
    		$($("[id*='draggable_second_factory_content_']")[this.length-1]).find(".right-div-comp-right-content-for-five").css("width","20%");
    		$($("[id*='draggable_second_factory_content_']")[this.length-1]).find("[name='order_s_input_val_feed_total']").attr("require_data_val","true");
    		$($("[id*='draggable_second_factory_content_']")[this.length-1]).find(".right-div-comp-right-content-for-six").css("width","20%");
    		$($("[id*='draggable_second_factory_content_']")[this.length-1]).find(".right-div-comp-right-content-for-six").show();
    		$($("[id*='draggable_second_factory_content_']")[this.length-1]).find(".right-div-comp-right-content-for-seven").hide();
    		$($("[id*='draggable_second_factory_content_']")[this.length-1]).find(".right-div-comp-right-content-for-eight").hide();
    		$($("[id*='draggable_second_factory_content_']")[this.length-1]).find(".right-div-comp-right-content-for-nine").hide();
    		return;
    	}
    	if(this.second_factory_data().special_val==700){//样式7
    		$($("[id*='draggable_second_factory_content_']")[this.length-1]).find(".right-div-comp-right-content").css("width","49%");
    		$($("[id*='draggable_second_factory_content_']")[this.length-1]).find(".right-div-comp-left-text").css("width","10%");
    		$($("[id*='draggable_second_factory_content_']")[this.length-1]).find(".right-div-comp-right-content-for-five").css("width","20%");
    		$($("[id*='draggable_second_factory_content_']")[this.length-1]).find("[name='order_s_input_val_feed_total']").attr("require_data_val","true");
    		$($("[id*='draggable_second_factory_content_']")[this.length-1]).find(".right-div-comp-right-content-for-seven").css("width","20%");
    		$($("[id*='draggable_second_factory_content_']")[this.length-1]).find(".right-div-comp-right-content-for-six").hide();
    		$($("[id*='draggable_second_factory_content_']")[this.length-1]).find(".right-div-comp-right-content-for-eight").hide();
    		$($("[id*='draggable_second_factory_content_']")[this.length-1]).find(".right-div-comp-right-content-for-nine").hide();
    		return;
    	}
    	if(this.second_factory_data().special_val==800){//样式8
    		$($("[id*='draggable_second_factory_content_']")[this.length-1]).find(".right-div-comp-right-content").css("width","49%");
    		$($("[id*='draggable_second_factory_content_']")[this.length-1]).find(".right-div-comp-left-text").css("width","10%");
    		$($("[id*='draggable_second_factory_content_']")[this.length-1]).find(".right-div-comp-right-content-for-five").css("width","20%");
    		$($("[id*='draggable_second_factory_content_']")[this.length-1]).find("[name='order_s_input_val_feed_total']").attr("require_data_val","true");
    		$($("[id*='draggable_second_factory_content_']")[this.length-1]).find(".right-div-comp-right-content-for-seven").css("width","10%");
    		$($("[id*='draggable_second_factory_content_']")[this.length-1]).find(".right-div-comp-right-content-for-six").hide();
    		$($("[id*='draggable_second_factory_content_']")[this.length-1]).find(".right-div-comp-right-content-for-eight").css("width","10%");
    		$($("[id*='draggable_second_factory_content_']")[this.length-1]).find(".right-div-comp-right-content-for-nine").hide();
    		return;
    	}
    	if(this.second_factory_data().special_val==900){//样式8
    		$($("[id*='draggable_second_factory_content_']")[this.length-1]).find(".right-div-comp-right-content").css("width","49%");
    		$($("[id*='draggable_second_factory_content_']")[this.length-1]).find(".right-div-comp-left-text").css("width","10%");
    		$($("[id*='draggable_second_factory_content_']")[this.length-1]).find(".right-div-comp-right-content-for-five").css("width","10%");
    		$($("[id*='draggable_second_factory_content_']")[this.length-1]).find("[name='order_s_input_val_feed_total']").attr("require_data_val","true");
    		$($("[id*='draggable_second_factory_content_']")[this.length-1]).find(".right-div-comp-right-content-for-seven").css("width","10%");
    		$($("[id*='draggable_second_factory_content_']")[this.length-1]).find(".right-div-comp-right-content-for-six").hide();
    		$($("[id*='draggable_second_factory_content_']")[this.length-1]).find(".right-div-comp-right-content-for-eight").css("width","10%");
    		$($("[id*='draggable_second_factory_content_']")[this.length-1]).find(".right-div-comp-right-content-for-nine").css("width","10%");
    		return
    		return;
    	}
    	$($("[id*='draggable_second_factory_content_']")[this.length-1]).find(".right-div-comp-right-content-for-five").hide();
		$($("[id*='draggable_second_factory_content_']")[this.length-1]).find(".right-div-comp-right-content-for-six").hide();
		$($("[id*='draggable_second_factory_content_']")[this.length-1]).find(".right-div-comp-right-content-for-seven").hide();
		$($("[id*='draggable_second_factory_content_']")[this.length-1]).find(".right-div-comp-right-content-for-eight").hide();
		$($("[id*='draggable_second_factory_content_']")[this.length-1]).find(".right-div-comp-right-content-for-nine").hide();
    },
    //加入feedTotal 没有feedTotal 增加并隐藏
    loadFeedTotal:function(){
    	var str=`<div class="right-div-comp-right-content-for-five">
        <textarea  class="textarea radius" name="order_s_input_val_feed_total" style="width:100%;height:100%;overflow: hidden;padding:2px;" placeholder="投料数(必填)"></textarea>
        <!--<input type="text" id="startDay" onclick="WdatePicker({maxDate:'%y-%M-%d',dateFmt:'yyyy-MM-dd'})"  class="input-text Wdate" style="width:100%;display: none">-->
    </div>`;
    	$("[id*='draggable_second_factory_content_']").each(function(index,el){
    		if($(this).find('.right-div-comp-right-content-for-five').length<1){
    			$(this).find(".right-div-comp-left-text").after(str);
    			$(this).find(".right-div-comp-right-content-for-five").hide();
    		}
    	})
    	//工艺
    	var str_arts=`<div class="right-div-comp-right-content-for-six">
        <textarea  class="textarea radius" name="order_s_input_val_arts" style="width:100%;height:100%;overflow: hidden;padding:2px;" placeholder="工艺"></textarea>
        <!--<input type="text" id="startDay" onclick="WdatePicker({maxDate:'%y-%M-%d',dateFmt:'yyyy-MM-dd'})"  class="input-text Wdate" style="width:100%;display: none">-->
    </div>`;
    	$("[id*='draggable_second_factory_content_']").each(function(index,el){
    		if($(this).find('.right-div-comp-right-content-for-six').length<1){
    			$(this).find(".right-div-comp-left-text").after(str_arts);
    			$(this).find(".right-div-comp-right-content-for-six").hide();
    		}
    	})
    	//材质
    	var str_quality_type=`<div class="right-div-comp-right-content-for-seven">
            <textarea  class="textarea radius" name="order_s_input_val_quality_type" style="width:100%;height:100%;overflow: hidden;padding:2px;" placeholder="材质"></textarea>
            <!--<input type="text" id="startDay" onclick="WdatePicker({maxDate:'%y-%M-%d',dateFmt:'yyyy-MM-dd'})"  class="input-text Wdate" style="width:100%;display: none">-->
        </div>`;
    	$("[id*='draggable_second_factory_content_']").each(function(index,el){
    		if($(this).find('.right-div-comp-right-content-for-seven').length<1){
    			$(this).find(".right-div-comp-left-text").after(str_quality_type);
    			$(this).find(".right-div-comp-right-content-for-seven").hide();
    		}
    	})
    	//是否读取颜色
    	var str_isReadColor = `<input type="text" hidden name="order_s_input_isReadColor" value="">`;
    	$("[id*='draggable_second_factory_content_']").each(function(index,el){
    		if($(this).find('[name="order_s_input_isReadColor"]').length<1){
    			$(this).find("[name='order_s_input_material_code']").after(str_isReadColor);
    		}
    	})
    	//说明
    	var str_remark=`<div class="right-div-comp-right-content-for-eight">
    	<div class="mydraggablehandler"></div>
        <textarea  class="textarea radius" name="order_s_input_val_remark" style="width:100%;height:100%;overflow: hidden;padding:2px;" placeholder="说明"></textarea>
        <!--<input type="text" id="startDay" onclick="WdatePicker({maxDate:'%y-%M-%d',dateFmt:'yyyy-MM-dd'})"  class="input-text Wdate" style="width:100%;display: none">-->
    </div>;`
		$("[id*='draggable_second_factory_content_']").each(function(index,el){
    		if($(this).find('.right-div-comp-right-content-for-eight').length<1){
    			$(this).find(".right-div-comp-right-content-for-six").after(str_remark);
    			$(this).find(".right-div-comp-right-content-for-eight").hide();
    		}
    	})
    	//供应商
    	var str_gys=`<div class="right-div-comp-right-content-for-nine">
	    	<div class="mydraggablehandler"></div>
	        <textarea  class="textarea radius" name="order_s_input_val_provider_name" style="width:100%;height:100%;overflow: hidden;padding:2px;" placeholder="说明"></textarea>
	        <!--<input type="text" id="startDay" onclick="WdatePicker({maxDate:'%y-%M-%d',dateFmt:'yyyy-MM-dd'})"  class="input-text Wdate" style="width:100%;display: none">-->
	    </div>;`
		$("[id*='draggable_second_factory_content_']").each(function(index,el){
    		if($(this).find('.right-div-comp-right-content-for-nine').length<1){
    			$(this).find(".right-div-comp-right-content-for-seven").after(str_gys);
    			$(this).find(".right-div-comp-right-content-for-nine").hide();
    		}
    	})
    },
    eventBind:function(){
        $("[id^='draggable_second_factory_content_']").find("[name='order_s_input_val_material_type']").unbind("click.dialog");
        
        $("[id^='draggable_second_factory_content_']").find("[name='order_s_input_val_material_type']").bind("click.dialog",function(){
            table_second_factory_input.sourceFactoryInputDialog(this);
        });
    },
    sourceFactoryInputDialog:function(self){
        var material_source_type = 
            $(self).parent().parent().find("[name='order_s_input_material_type']").text();
        var isreadcolor = 
            $(self).parent().parent().find("[name='order_s_input_isReadColor']").val();
        var father = $(self).parent().parent().parent().parent().attr("id");
        //console.info($(self).attr("name"));
        $('div#easyui_dialog_second_input').dialog({
            modal: true,
            title: '请选择',
            width: "500",
            height: "400",
            closed: false,
            border:false,
            cache: false,
            resizable: true,
            content:"<iframe frameborder='0' scrolling='no' style='width:99%;height:97%;' src='second_factory_input_dialog.html?material_second_type="+material_source_type+"&ev="+$(self).attr("name")+"&father="+father+"&isreadcolor="+isreadcolor+"'></iframe>",
            onClose : function() {  
               table_second_factory_input.destroydialog();
            }
        });
    },
    destroydialog:function(){
        $("div#easyui_dialog_second_input").dialog('destroy');  
        $("body").append("<div id='easyui_dialog_second_input'></div>");
    }
}

table_second_factory_input.eventBind();
table_second_factory_input.loadFeedTotal();